<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="string" uri="http://jakarta.apache.org/taglibs/string-1.1" %>
<%@ taglib uri="/WEB-INF/tlds/pagination.tld" prefix="pagination" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Bettersoft Portal</title>
    <link href="/common/css/indexStyle.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="/common/js/common.js"></script>
    <script type='text/javascript' src="/common/dwr/engine.js"></script>
    <script type='text/javascript' src="/common/dwr/util.js"></script>
    <script type='text/javascript' src='/dwr/interface/BettersoftPortalService.js'></script>

    <script type="text/javascript">
        // Locale 설정을 바꾼다.
        function jsChangeLocale(lan) {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "intro";
            TheForm.action = "${pageContext.request.contextPath}/changeLocale.do?language=" + lan;
            TheForm.submit();
        }

        // Notice Board List 페이지로 이동한다.
        function jsNoticeBoardList() {
            var TheForm = document.menuFrm;
            TheForm.title.value = TheForm.search_title.value;
            TheForm.writer_id.value = TheForm.search_writer.value;
            TheForm.writer_nick_name.value = TheForm.search_nickName.value;
            TheForm.content.value = TheForm.search_content.value;
            TheForm.nextTarget.value = "noticeBoardList";	// page name
            TheForm.action = "./noticeBoardList.do";
            TheForm.submit();
        }

        // Community Board List 페이지로 이동한다.
        function jsCommunityBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "communityBoardList";	// page name
            TheForm.action = "./communityBoardList.do";
            TheForm.submit();
        }

        // Member List 페이지로 이동한다.
        function jsMemberList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "memberList";	// page name
            TheForm.action = "./memberList.do";
            TheForm.submit();
        }

        // frm 의 첨부파일 버튼 초기화
        function jsFileReset() {
            var obj = eval("frm.PROFILE_IMAGE");
            var obj2 = obj.cloneNode(false);
            obj.parentNode.replaceChild(obj2, obj);
            // obj 에 원래 file 필드를 가져와서 clone 노드 obj2 와 바꿔치기
        }

        // 그림파일인지 검사
        function jsFileType(){
            if( !event.srcElement.value.match(/(.jpg|.jpeg|.gif|.png|.JPG|.GIF|.PNG)/)) {
                alert('그림형식의 파일이 아닙니다.(jpg, gif, png 형식의 파일 업로드 가능)');
                jsFileReset();
            }
        }


        // Member List 페이지로 이동한다.
        function jsUpdateMember() {

            var TheForm = document.frm;

            // 이메일 유효성 검사
            if(TheForm.EMAIL.value.search(/(\S+)@(\S+)\.(\S+)/) == -1) {
                alert("이메일 형식이 잘못되었습니다.");
                TheForm.EMAIL.value = '';
                TheForm.EMAIL.focus();

                // 연락처 미입력
            }else if(trim(TheForm.PHONE.value) == ""){
                alert('연락처를 입력하세요');
                TheForm.PHONE.focus();

                // 연락처 공백 검사
            }else if(checkSpace(TheForm.PHONE.value) == 1){
                alert('연락처에 공백이 들어갈 수 없습니다.');
                TheForm.PHONE.value = '';
                TheForm.PHONE.focus();

                // 이름 미입력
            }else if(trim(TheForm.NAME.value) == ""){
                alert('이름을 입력하세요');
                TheForm.NAME.focus();


            }else {
                TheForm.nextTarget.value = "memberUpdateResult";	// page name
                TheForm.action = "memberUpdateAction.do";
                TheForm.submit();
            }
        }

        // 띄어쓰기 체크
        function checkSpace(str)
        {
            if(str.search(/\s/) != -1){
                return 1;
            }
            else {
                return "";
            }
        }




    </script>
</head>
<body>
<!------------------------------ top 시작-------------------------------------->
<%@include file="portalHeader.jsp" %>
<!------------------------------ top 끝-------------------------------------->
<form name="frm" method="POST" enctype="multipart/form-data" onkeypress="if(event.keyCode == 13) {return false;}" >
    <input type="hidden" id="PROFILE_IMAGE_URL"    name="PROFILE_IMAGE_URL"   value="${member.PROFILE_IMAGE_URL}">
    <input type="hidden" id="nextTarget"    name="nextTarget"   value="">
    <div id="intro" style="height: 100%">
        <br/><br/><br/><br/><br/><br/><br/><br/><br/>
        <div id="login">
            <p align="center"><label for="BETTERSOFT_ID">아&nbsp;&nbsp;이&nbsp;&nbsp;디</label><input type="text" value="${member.BETTERSOFT_ID}" name="BETTERSOFT_ID" id="BETTERSOFT_ID" readonly /></p>
            <p align="center"><label for="EMAIL">이메일</label><input type="text" value="${member.EMAIL}" name="EMAIL" id="EMAIL" /></p>
            <p align="center"><label for="NAME">이름</label><input type="text" value="${member.NAME}" name="NAME" id="NAME" /></p>
            <p align="center"><label for="PHONE">전화번호</label><input type="text" value="${member.PHONE}" name="PHONE" id="PHONE" /></p>
            <p align="center">
                <label for="RANK">직급</label>
                <select size="1" name="RANK" id="RANK">
                    <option value="1"
                            <c:if test="${member.RANK == '1'}">
                                selected
                            </c:if>
                            >사원</option>
                    <option value="2"
                            <c:if test="${member.RANK == '2'}">
                                selected
                            </c:if>
                            >주임</option>
                    <option value="3"
                            <c:if test="${member.RANK == '3'}">
                                selected
                            </c:if>
                            >대리</option>
                    <option value="4"
                            <c:if test="${member.RANK == '4'}">
                                selected
                            </c:if>
                            >과장</option>
                    <option value="5"
                            <c:if test="${member.RANK == '5'}">
                                selected
                            </c:if>
                            >차장</option>
                    <option value="6"
                            <c:if test="${member.RANK == '6'}">
                                selected
                            </c:if>
                            >부장</option>
                    <option value="7"
                            <c:if test="${member.RANK == '7'}">
                                selected
                            </c:if>
                            >이사</option>
                    <option value="8"
                            <c:if test="${member.RANK == '8'}">
                                selected
                            </c:if>
                            >대표</option>
                </select>
            </p>
            <p align="center"><label for="PROFILE_IMAGE">사진</label><br>
                <c:if test="${member.PROFILE_IMAGE_URL != ''}">
                    <img src="/upload/profile/${member.PROFILE_IMAGE_URL}" style="width: 120px; height: 120px;">
                </c:if>
                <c:if test="${member.PROFILE_IMAGE_URL == ''}">
                    <img src="/upload/profile/empty.jpg" style="width: 120px; height: 120px;">
                </c:if>
                <br>
                <input type="file" name="PROFILE_IMAGE" id="PROFILE_IMAGE" onchange="jsFileType()"  /><a href="javascript:jsFileReset()">삭제</a>
            </p>
        </div>
        <div class="int_btn" align="center">
            <a href="javascript:jsUpdateMember()" id="login_btn" class="btn btn_nr" style="color: #888888;"><b>변경</b></a>
            &nbsp;&nbsp;
            <a href="portalIndex.do" id="register_btn" class="btn btn_nr" style="color: #888888;"><b>취소</b></a>
        </div>

    </div>
</form>
<!------------------------------ top 시작-------------------------------------->
<%@include file="portalFooter.jsp" %>
<!------------------------------ top 끝-------------------------------------->
</body>
</html>